package demo.practice.leetcode_eveyday;

import java.util.HashMap;
import java.util.Map;

public class P509 {


    Map<Integer, Integer> map = new HashMap<>();

    public int fib(int n) {
        if (map.get(n) == null) {
            map.put(n, n == 0 || n == 1 ? n : fib(n - 1) + fib(n - 2));
        }
        return map.get(n);
    }

}
